import requests
import json


# 新建会话，得到conversation_id
def main():
        
    url = "https://qianfan.baidubce.com/v2/app/conversation"
    
    payload = json.dumps({
        "app_id": "6c31123d-6103-4e6d-a546-f8fce6555807"
    })
    headers = {
        'Content-Type': 'application/json',
        'X-Appbuilder-Authorization': 'Bearer bce-v3/ALTAK-WT80OnqVYqiuiXVWpaWYc/448dafad3a1809cdd625d6aeb7b337e73556999d'
    }
    
    response = requests.request("POST", url, headers=headers, data=payload)
    
    print(response.text)
    print(type(response.text))
    # 从以上json字符串中提取conversation_id
    data = json.loads(response.text)
    conversation_id = data['conversation_id']
    print(conversation_id)


    

if __name__ == '__main__':
    main()
